﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using brockredge.CLASSES;

namespace brockredge.handler
{
    /// <summary>
    /// Summary description for getCitiesbyState
    /// </summary>
    public class getCitiesbyState : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                //context.Response.ContentType = "text/plain";
                testDataContext tdc = new testDataContext();
               
                var cityQ = from city in tdc.City_States
                            where tdc.States.Any(s=>s.state_id==city.state_id && s.state_name==context.Request.QueryString["s"])
                            select city.City;
                List<String> CityList = new List<String>();
                foreach (var city in cityQ)
                {
                    CityList.Add(city.city_name);
                }
                context.Response.Write(CityList);
            }
            catch (Exception ex) { }
           
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}